/*
 * SessionModel.java
 * 
 * Created on Sep 10, 2007, 7:54:02 PM
 * 
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package org.oslo.ui.util;

import java.util.List;
import javax.swing.event.TableModelListener;
import javax.swing.table.TableModel;
import org.oslo.sessioninfo.domain.SessionInfo;

/**
 *
 * @author nl24167
 */
public class SessionModel implements TableModel {
    
    private String[] columns = new String[] {"title","start-time","end-time","day","speaker"};
    
    private final static int TITLE=0;
    private final static int START_TIME=1;
    private final static int END_TIME=2;
    private final static int DAY=3;
    private final static int SPEAKER=4;
    
    private List<SessionInfo> info;
    
    public SessionModel(List<SessionInfo> sessionInfo) {
        info = sessionInfo;
    }

    public int getRowCount() {
        return info.size();
    }

    public int getColumnCount() {
        return columns.length;
    }

    public String getColumnName(int columnIndex) {
        return columns[columnIndex];
    }

    public Class<?> getColumnClass(int columnIndex) {
        return String.class;
    }

    public boolean isCellEditable(int rowIndex, int columnIndex) {
        return false;
    }

    public Object getValueAt(int rowIndex, int columnIndex) {
        Object result = "";
        SessionInfo session = info.get(rowIndex);
        
        switch (columnIndex) {
        case START_TIME:
            result = session.getStartTime();
            break;
        case TITLE:
            result = session.getTitle();
            break;
        case SPEAKER :
            result = session.getSpeakerName();
            break;
        case DAY:
            result = session.getDay();
            break;
        case END_TIME:
            result = session.getEndTime();
            break;
        default:
            break;
        }
        
        return result;
    }

    public void setValueAt(Object aValue, int rowIndex, int columnIndex) {
        throw new UnsupportedOperationException("Not supported yet.");
    }

    public void addTableModelListener(TableModelListener l) {
        System.out.println("Adding table model listener");
    }

    public void removeTableModelListener(TableModelListener l) {
        System.out.println("Removing table model listener");
    }

}
